package com.twd.netty;

import java.util.concurrent.*;

public class MyFutrueTest {
    public static void main(String[] args) {
        MyFuture myFuture=new MyFuture();
        MyFuture execute = myFuture.execute(() -> {
//            TimeUnit.SECONDS.sleep(2);
            return "aaaaaaaa";
        });
        execute.setlis((s)->{
            System.out.println(s);
        });
    }
}
class MyFuture{
    lis l;
    public MyFuture execute(Callable<String> c){
        FutureTask<String> f=new FutureTask<String>(c);
        new Thread(f).start();
        new Thread(()->{
            try {
                String s = f.get();
                dlis(s);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

        }).start();
        return this;
    }

    public void setlis(lis l){
        this.l=l;
    }
    public void dlis(String s){
        l.doa(s);
    }
}
interface   lis{
    public void doa(String s);
}
